<% add_decidim_page_title(t(".title")) %>

<% provide :title do %>
  <h1 class="h1"><%= t ".title" %></h1>
<% end %>

<%= link_to t("actions.new_oauth_application", scope: "decidim.system"), [:new, :oauth_application], class: "button button__sm md:button__lg button__primary" %>

<table>
  <thead>
    <tr>
      <th></th>
      <th><%= t("models.oauth_application.fields.name", scope: "decidim.system") %></th>
      <th><%= t("models.oauth_application.fields.organization_name", scope: "decidim.system") %></th>
      <th><%= t("models.oauth_application.fields.created_at", scope: "decidim.system") %></th>
      <th><%= t("actions.title", scope: "decidim.system") %></th>
    </tr>
  </thead>
  <tbody>
    <% @oauth_applications.each do |oauth_application| %>
      <tr>
        <td>
          <%= image_tag oauth_application.attached_uploader(:organization_logo).url, class: "max-w-md" %>
        </td>
        <td>
          <%= link_to oauth_application.name, oauth_application %><br>
        </td>
        <td>
          <%= link_to oauth_application.organization_name, edit_organization_path(oauth_application.organization) %><br>
        </td>
        <td>
          <%= l oauth_application.created_at, format: :short %>
        </td>
        <td>
          <%= link_to t("actions.edit", scope: "decidim.system"), [:edit, oauth_application] %>
          <%= link_to t("actions.destroy", scope: "decidim.system"), oauth_application, method: :delete, data: { confirm: t(".confirm_delete") } %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
